package org.adoxx.lbrsws.client; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import javax.xml.rpc.holders.IntHolder; import javax.xml.rpc.holders.StringHolder; import com.boc_eu.www.LBRS_wsdl.LBRSWSLocator; import com.boc_eu.www.LBRS_wsdl.LBRSWSSoapBindingStub; public class ReadModel { /** * @param args * @throws ServiceException * @throws MalformedURLException * @throws RemoteException */ public static void main(String[] args) throws MalformedURLException, ServiceException, RemoteException { /* * Initialize the client, provide endpoint address of respective LBRSWS * service (in the example below LBRSWS has been started on port 8080 and the respective context - * it http://localhost:8080/LBRSWS/services/LBRSWS) */ LBRSWSSoapBindingStub binding = (LBRSWSSoapBindingStub) new LBRSWSLocator().getLBRSWS(new URL ("http://localhost:8080/LBRSWS/services/LBRSWS")); /* * Initialize result holder objects * * errorCode ... returns the errorCode of the AdoScript as documented in * AdoScript section of Development Toolkit Handbook * * result ... String result from running the AdoScript */ IntHolder errorCode = new IntHolder(); StringHolder result = new StringHolder(); /* * Sample implementation of query AdoScript in a static class for re-use * * For this example a model of type "Sample" named "Demonstration" must exist. * The AdoScript sets the result in an AdoScript variable "result" and puts in into the * StringHolder of above */ String script = QueryScripts.getAllInstancesOfModelByName( "Demonstration", "Sample", "result"); /* * Execute AdoScript on LBRSWS, for parameters see LBRSWS documentation on installation CD */ String waitTime = "1000"; String executtime = "1000"; String retries = "3"; String usertype = "usertypeone"; String parameter = "xx13ul1"; String resultVar = "result"; binding.execute(waitTime, executtime, retries, usertype, parameter, script, resultVar , errorCode, result); /* * Prints the result into System.out * */ printResults(result.value, System.out); } private static void printResults(String value, PrintStream out) { String[] objects = value.split(" "); for (int i = 0; i < objects.length; i++) { out.println("Model contains object with ID: " + objects[i]); } } }